import os

from CaseAW.GridBase import winAppBase



class view_base(winAppBase):
    def viewer_assert(self,expect_path,actual_path,differ_num=99):
        """
        视图区域截图，定制裁剪边框,若要替换预期，就不要屏蔽预期截图，正常执行时，屏蔽预期截图即可
        """
        # self.picture_shot("classname","QViewerItem",expect_path,offset=(7,5,-60,-12))
        self.picture_shot("classname","QViewerItem",expect_path,offset=(7,5,-60,-12))
        self.picture_assert2(expect_path,actual_path,threshold=differ_num)

    def viewer_assert_small(self,expect_path,actual_path,differ_num=99,offset=(250,20,-500,-40)):
        # self.picture_shot("classname","QViewerItem",expect_path,offset=offset)
        self.picture_shot("classname","QViewerItem",expect_path,offset=offset)
        self.picture_assert2(expect_path,actual_path,threshold=differ_num)

    def viewer_assert_BDD(self,index,differ_num=99,offset=(250,20,-500,-40)):
        """
        视图区检查
        """
        expect_path=self.work_file_dir+os.sep+"expect_%s.jpg"%(str(index))
        actual_path= self.work_file_dir + os.sep + "actual_%s.jpg" % (str(index))
        # self.picture_shot("classname","QViewerItem",expect_path,offset=offset)
        self.picture_shot("classname","QViewerItem",expect_path,offset=offset)
        self.picture_assert2(expect_path,actual_path,threshold=differ_num)
